-
Notifications
You must be signed in to change notification settings - Fork 3
chore: DSPX-1226 use key ids per attribute #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: DSPX-1226 use key ids per attribute #634
Conversation
…px-1226/use-key-ids-per-attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ntrevino-virtru, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request implements a comprehensive update to the core key management and policy enforcement mechanisms within the system. It introduces new data models and refactors existing client-side logic to provide more explicit control over Key Access Server (KAS) key identification, management, and their association with policy attributes. Additionally, it enhances OpenID Connect (OIDC) integration by allowing configurable endpoints and lays groundwork for advanced key lifecycle management features.
Highlights
- Key Management Overhaul: Introduced new
SimpleKasKey
,PublicKeyCtx
, andPrivateKeyCtx
types, and updated core policy objects (Namespace
,Attribute
,Value
,KeyAccessServer
) to utilize these new, more explicit key representations. This includes changes to how KAS keys are associated with attributes and values. - Enhanced Key Modes: Expanded the
KeyMode
enum with detailed classifications likeCONFIG_ROOT_KEY
,PROVIDER_ROOT_KEY
, andPUBLIC_KEY_ONLY
, providing more granular control over key management strategies. - Configurable OIDC Endpoints: Added the capability to explicitly configure OIDC token and user info endpoints within authentication providers, enhancing flexibility for OIDC integration.
- Key Rotation and Base Key Management: Introduced new RPC methods (
SetBaseKey
,GetBaseKey
) and response structures (RotatedResources
) in the KAS registry, enabling more robust management and tracking of key rotations. - Client-Side Key Resolution Refactor: The TDF3 client's key resolution logic was significantly refactored to use a caching mechanism for KAS public keys and to correctly handle various public key contexts (remote, cached) during the encryption process, including the use of explicit Key IDs (
kid
).
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Reated to #622 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces several significant changes, primarily focused on enhancing OIDC endpoint configurability and refactoring how key identifiers and attributes are handled, particularly within the policy and TDF3 client logic.
Key changes include:
- Adding
oidcTokenEndpoint
andoidcUserInfoEndpoint
options for more flexible OIDC integration. - Substantial updates to Protobuf definitions, including new message types (
SimpleKasKey
,PublicKeyCtx
, etc.), changes to existing enums (KeyStatus
,KeyMode
), and the removal ofgoogle.api.http
options from many gRPC services. These are potentially breaking changes that need careful consideration and documentation. - Refactoring of the policy granter logic to use
KeyAccessServer
objects more directly and incorporatekid
(Key ID) into the key splitting plan, aligning with the PR's goal of using key IDs per attribute. - Updates to the TDF3 client to support these new KAS key handling mechanisms, including a more detailed
splitPlan
and caching for KAS public key fetching.
Several critical issues have been identified, primarily related to the Protobuf changes, such as the removal of HTTP/JSON transcoding annotations and a suspicious field name/type swap in RotateKeyRequest_NewKey
. These require immediate attention. The PR description should be updated to reflect these significant changes and their potential impact.
…ey-ids-per-attribute # Conflicts: # lib/src/opentdf.ts # lib/tdf3/src/client/index.ts
@@ -282,7 +295,7 @@ export function valueFor(attr: string): Value { | |||
if (!(attr in values)) { | |||
throw new Error(`invalid FQN [${attr}]`); | |||
} | |||
console.log('value for', attr, 'is', values[attr]); | |||
// console.log('value for', attr, 'is', values[attr]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we remove this?
? splitPlan | ||
: [{ kas: opts.defaultKASEndpoint ?? this.kasEndpoint }]; | ||
// TODO KAS: check here | ||
if (splitPlan.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably will have Eugene's base key work here I believe.
lib/tdf3/src/client/index.ts
Outdated
const splits: SplitStep[] = splitPlan?.length | ||
? splitPlan | ||
: [{ kas: opts.defaultKASEndpoint ?? this.kasEndpoint }]; | ||
// TODO KAS: check here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I missing the step where we are adding SimpleKasKeys to the kasKeys cache? The flow should be the following:
An attribute comes back with:
- Grants/SimpleKasKeys
If we notice that the response has KasKeys we use those instead of the grants returned, else use the grants.
Example of this in the golang sdk:
https://github.com/opentdf/platform/blob/main/sdk/granter.go#L287-L304
…px-1226/use-key-ids-per-attribute
…ey-ids-per-attribute
|
return [keyHolder, keyParts.join('/')] as [KeyHolder, string]; | ||
}) | ||
.sort(([, sortKeyA], [, sortKeyB]) => { | ||
return sortKeyA.localeCompare(sortKeyB); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really nice 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through the code changes and LGTM
No description provided.